﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Private.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="WebHoiChoMuaBan.Models"  %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Helpers" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Utility" %>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleHolder" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadHolder" runat="server">
    <style type="text/css" media="screen">
		.error { font-weight: Bold; color: Red; }
	</style>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentHolder" runat="server">
    <% 
        var hMem = (MemberHelper)ViewData["hMem"];  
    %>
    <div class="private_rightbottom_content">
        <div class="private_rightbottom_contentleft">
        <div class="private_share_post">
                <div class="private_share_post_top">
                    <div class="private_sharepost_menu">
                        <ul>
                            <li><a href="#" class="menu_select">Quảng cáo</a></li>
                        </ul>
                    </div>
                </div>
            <% 
                if(Session["MemId"] != null)
                {
                    //Check if this member is owner of this page or not
                    if (hMem.Member.MemId == (int)Session["MemId"])
                    {
                %>
                    <%=Html.ValidationSummary("Vui lòng nhập đầy đủ thông tin.", new { @class= "error"})%>
                    <form action="<%=Url.Action("Add","Advertisement") %>" id="frm_AddAlbum" method="post" enctype="multipart/form-data">
                        <div class="private_comment_top">
                            <table width="100%" border="0">
                                <tr>
                                    <td><input type="hidden" name="MemId" id="MemId" value=<%=ViewData["MemId"] %> /></td>
                                </tr>
                                <tr>
                                    <td width="16%" align="right" valign="middle" class="private_font_bold">Tiêu đề</td>
                                    <%--<td width="84%"><input type="text" name="txtTitle" id="txtTitle" class="input_full"/></td>--%>
                                    <td width="84%"><%= Html.TextBox("txtTitle", ViewData["Advertisement"] == null ? "" : ((Advertisment)ViewData["Advertisement"]).AdTitle, new { @class = "input_full" })%></td>
                                </tr>
                                <tr>
                                    <td align="right" valign="middle" class="private_font_bold">Link website</td>
                                    <%--<td><input type="text" name="txtLink" id="txtLink" class="input_full"/></td>--%>
                                    <td><%= Html.TextBox("txtLink", ViewData["Advertisement"] == null ? "" : ((Advertisment)ViewData["Advertisement"]).AdLink, new { @class = "input_full"})%></td>
                                </tr>
                                <tr>
                                    <td align="right" valign="middle" class="private_font_bold">Giá tiền</td>
                                    <%--<td><input type="text" name="txtPrice" id="txtPrice" class="input_full"/></td>--%>
                                    <td><%= Html.TextBox("txtPrice", ViewData["Advertisement"] == null ? null : ((Advertisment)ViewData["Advertisement"]).AdPrice, new { @class = "input_full"})%></td>
                                </tr>
                                <tr>
                                    <td align="right" valign="top" class="private_font_bold">Nội dung</td>
                                    <td><label for="textarea"></label>
                                    <%--<textarea name="txtContent" id="txtContent" cols="45" rows="5" class="input_full"></textarea></td>--%>
                                    <%= Html.TextArea("txtContent", ViewData["Advertisement"] == null ? "" : ((Advertisment)ViewData["Advertisement"]).AdContent, new { @class = "input_full"})%>

                                </tr>
                                <tr>
                                    <td align="right" valign="top" class="private_font_bold">Hình minh họa</td>
                                    <td><input type="file" name="imgAdvert" id="imgAdvert"/></td>
                                </tr>
                                <tr>
                                <td align="right" colspan="2">
                                    <input type="submit" id="" value="Đăng quảng cáo" class="private_bt_submit_news" style="width:145px;"/>	
                                </td>
                                </tr>
                            </table>
                        </div>
                    </form>
                    <%} }%>
                <hr class="private_color_hr"/>
                <%--<!-- Thum ad hot -->
                <div class="private_thumb_listpr">
                    <div class="private_img_post_bt">
                        <a href="canhan_sp_detail_private.html"><img src="/../Content/Images/img_list_product.gif" class="private_img_post"/></a>
                    </div>
                    <div class="private_post_text">
                        <p class="private_text_title">Nam felis est, mattis sit amet tempor non, mattis sed lectus.</p>
                        <p>
                            Suspendisse felis erat, tristique nec bibendum ut, tempor ullamcorper magna. Suspendisse varius erat vitae felis sagittis a hendrerit odio consequat. Mauris nec tortor a sem accumsan gravida sed non nulla
                            <br /><strong>Giá bán:&nbsp;</strong><span class="private_price">600000</span><sup class="private_cur">đ</sup>
                        </p><br />
                        <div class="private_listpr_active">
                            <div class="private_content_rp">
                            <div class="private_upload_adhot"><a href="#">Up quảng cáo hot</a></div>
                            </div>
                            <div class="private_content_rp">
                            <div class="private_upload_adhot"><a href="#">Check hiển thị</a></div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- End Thum ad hot -->--%>
                <%
                    int i;
                    AdvertHelper.FetchAdvertisementResult lstAdvertisement = (AdvertHelper.FetchAdvertisementResult)ViewData["ListAdvertisement"];
                    if (lstAdvertisement.advertisement.Count > 0)
                    {
                        foreach (var item in lstAdvertisement.advertisement)
	                    {
		                    Response.Write("<div class='private_thumb_listpr'>");
                            Response.Write("<div class='private_img_post_bt'>");
                            Response.Write("<a href='"+item.AdLink+"'><img src='/../Content/Images/Upload/" + item.AdThumb + "' width='140' height='101' class='private_img_post' /></a></div>");
                            Response.Write("<div class='private_post_text'>");
                            Response.Write("<p class='private_text_title'><a href='"+item.AdLink+"'>" + item.AdTitle + "</a></p>");
                            Response.Write("<p style='width:400px'>" + item.AdContent + "<br /><strong>Giá bán:&nbsp;</strong><span class='private_price'>" + String.Format("{0:0,0}", item.AdPrice) + "</span><sup class='private_cur'>đ</sup></p><br />");
                            Response.Write("<div class='private_listpr_active'>");
                            Response.Write("<div class='private_content_rp'>");
                            Response.Write("<div class='private_upload_adhot'><a href='#'>Up quảng cáo hot</a></div></div>");
                            Response.Write("<div class='private_content_rp'>");
                            if (item.AdState == 0)
                            {
                                Response.Write("<div class='private_upload_adhot'><a href='' onclick='disibleAd(" + item.AdId + ")'>Hiện hiển thị</a></div></div></div></div></div>");
                            }
                            else
                            {
                                Response.Write("<div class='private_upload_adhot'><a href=''onclick='disibleAd(" + item.AdId + ")'>Ẩn hiển thị</a></div></div></div></div></div>");
                            }
	                    }
                    }
                %>
                <center>

            <div class="private_breakpage">
                <%
                    int p;
                    if (Request.QueryString["p"] == null && !int.TryParse(Request.QueryString["p"], out p))
                    {
                        p = 1;
                    }
                    else p = int.Parse(Request.QueryString["p"]);
                     %>
                <% if (p > 1)
                   { %><a href='<%=string.Format("{0}?p={1}'",
                                                        Url.Action("Index", "Advertisement"),
                                                        p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
                <%
                   if (p > 3)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "Advertisement"),
                                                       1,
                                                       string.Empty,
                                                        1));
                   if (p > 4)
                       Response.Write("...");
                   int total = lstAdvertisement.totalPages;
                   int from = (p - 2 < 1 ? 1 : p - 2);
                   int to = (p + 2 >= total ? total : p + 2);
                   for (i = from; i <= to; i++)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "Advertisement"),
                                                       i,
                                                       (i == p ? "class='menu_select'" : string.Empty),
                                                        i));
                   if (p <= total - 4)
                       Response.Write("...");
                   if (p <= total - 3)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "Advertisement"),
                                                       total,
                                                       string.Empty,
                                                       total));
                 %>
            
                <% if (p < lstAdvertisement.totalPages)
                   { %><a href='<%=string.Format("{0}?p={1}#noibat'",
                                                        Url.Action("Index", "Advertisement"),
                                                        p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
            </div>
        </center>
        </div>
        </div>
</div>

</asp:Content>


